home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12127 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: altair.herts.ac.uk!cs4bb
  2. From: 'Pink Budgie' <cs4bb@herts.ac.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Huge pointer with farcalloc()
  5. Date: Fri, 29 Mar 1996 10:11:55 +0000
  6. Organization: University of Hertfordshire
  7. Message-ID: <Pine.SUN.3.91.960329095306.3773A-100000@altair.herts.ac.uk>
  8. NNTP-Posting-Host: altair.herts.ac.uk
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11.  
  12. I'm having problems allocating a large (well huge) pointer array for an 
  13. image buffer (800Kb+) using huge pointers and farcalloc under Borland C(++) 
  14. v4.02.
  15.  
  16. farcalloc returns a void far * which means (I assume) I can create a huge 
  17. pointer and point it at my far buffer thus:
  18.  
  19. BYTE far *farptr;
  20. BYTE huge *hugeptr;
  21.  
  22. farptr = (BYTE far *)farcalloc((unsigned long)5, (unsigned long)100,000);
  23. hugeptr = (BYTE huge *)farptr;
  24.  
  25.  
  26. I actually got this to work if I did it exactly like this.  But 
  27. the problem I am having is when I try and add a second far pointer to 
  28. point to a smaller farmalloc like this (added to the above):
  29.  
  30. BYTE far *anotherfarptr;
  31.  
  32. anotherfarptr = (BYTE far *)farmalloc(2048);
  33.  
  34.  
  35. Then I need to transfer the contents of *anotherfarptr (a single image 
  36. scanline) to *hugeptr (pointing to the complete image) like this:
  37.  
  38. for (x = 0; x < xSize; x++) {
  39.     *hugeptr++ = anotherfarptr[2];
  40.     *hugeptr++ = anotherfarptr[1];
  41.     *hugeptr++ = anotherfarptr[0];
  42.     anotherfarptr+=3;
  43. }
  44.  
  45. ....and so it goes on.
  46.  
  47. This is necessary as I am converting PCX to BMP so the scanlines are inverted 
  48. laterally.  Whenever I do it this way my *hugeptr becomes a far pointer 
  49. (and thus my whole image buffer is garbled when the end of the segment is 
  50. reached).
  51.  
  52. Can anyone suggest how to bypass this?  I imagine I am not using the 
  53. correct method for using huge pointers, but the documentation is vague.
  54.  
  55. Please could any answers be copied to my email (M.G.Ross@herts.ac.uk) as 
  56. I don't often get onto these groups.  Thanks for any help.
  57.  
  58. Matt Ross
  59.